#pragma once
#ifndef BODY_H
#define BODY_H

#include<list>
#include<graphics.h>
#include <string>

#include"Vector_2D.h"

const double PI = acos(0) * 2;
#define G 0.35

class Body
{
private:
    constexpr static short density = 1;	//密度
    unsigned m;
    double r;

    bool locked;//位置是否锁定(locked==1为锁定)
    int num;//编号
    static size_t maxPath;	//最长轨迹

    COLORREF col;			//颜色	

   std::list<Position> path;	//轨迹

    Position pos;
    Vector_2D v;
    Vector_2D F;
    Vector_2D a;

    void cal_r()//计算、或改变半径
    {
        r = pow((this->m) / (4 * PI * density) +
            (this->m) / (4 * PI * density) +
            (this->m) / (4 * PI * density),
            1.0 / 3);
    }
    
    friend class MultiBody;
public:
    Body();
    Body(unsigned mass, Position pos0, Vector_2D v0,COLORREF color, int number);
    Body(unsigned mass, int pos_x,int pos_y,double v_x,double v_y, COLORREF color, int number);
   
    void show() const;
    void move();

    void cal_a();//计算加速度
    void change_v();

    bool isLocked() const;
    void set_Lock(bool flag);
};

#endif // BODY_H